package com.example.mapper;

import com.example.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository
public interface UserMapper extends BaseMapper<User> {

    @Insert("INSERT into user(id,username,password,phone)VALUES(#{username},#{password},#{phone})")
    int saveUser(@Param("username") String username, @Param("password") String password);

    @Select("select id,useername,password form user where username=#{username}}")
    User selectUser(@Param("username") String username);

    // 一对多查询
//    Page<com.example.entity.User> findPage(Page<com.example.entity.User> page, @Param("nickName") String nickName);

//    @Select("select count(id) count, address from user GROUP BY address")
//    List<UserAddressDto> countAddress();

    // 查询用户名
//    @Select("select password from user where username=#{username}")
//    User selectByName(String username);
//
//    @Update("update user set password = #{newPass} where id = #{userId}")
//    int updatePass(Map<String, Object> map);

}

